﻿
function getObjById(id) {
    if (document.getElementById)
        var returnVar = document.getElementById(id);
    else if (document.all)
        var returnVar = document.all[id];
    else if (document.layers)
        var returnVar = document.layers[id];
    return returnVar;
}

function showElement(id) {
    var myVal = getObjById(id);
    if (myVal == null || myVal == undefined) {
    }
    else {
        myVal.style.display = 'block';
    }
}

function hideElement(id) {
    var myVal = getObjById(id);
    if (myVal == null || myVal == undefined) { }
    else {
        myVal.style.display = 'none';
    }
}

function Addclass(id) {
    var myVal = getObjById(id);
    if (myVal == null || myVal == undefined) { }
    else {
        myVal.className = 'errHilite';
    }
}
function Removeclass(id) {
    var myVal = getObjById(id);
    if (myVal == null || myVal == undefined) { }
    else {
        myVal.className = '';
    }
}
function trim(sString) {
    if (sString == null) {
        return "";
    }
    if (sString.length == undefined) {
        return "Skip this item";
    }

    while (sString.length != 0) {
        if (sString.substring(0, 1) == ' ') {
            sString = sString.substring(1, sString.length);
        }
        else break;
    }
    while (sString.length != 0) {
        if (sString.substring(sString.length - 1, sString.length) == ' ') {
            sString = sString.substring(0, sString.length - 1);
        }
        else
            break;
    }
    return sString;
}

function checkemail(email) {

    var emailPattern = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/;
    return emailPattern.test(email);
}

